<template>
    <div class="auction">
        <v-navbar/>
        <div class="auction_container">
            <!-- 标题 -->
            <div class="auction_title">
                <div class="auction_titlelist" :class="{activeAuction:auctionIndex == v.id}" v-for="(v,i) in auctionTitle" :key="i" @click="e_actionTitle(v.id)">
                    <span v-text="v.title" />
                </div>
            </div>
            <!-- 列表 -->
            <v-auctionUl :auctionUlList='auctionUlList' />
        </div>
    </div>
</template>

<script>
import navbar from '@c/navbar/navbar'
import { mapState, mapMutations } from 'vuex'
import { vpost, sonpost, fpost, gpost, vlink } from '@api/axios'
import { tokenPost, jtpost, gtpost, tokenLink, jtget } from '@api/axiosByToken'
import auctionTitle from './titlelist'
import auctionUl from './auctionUl'
export default {
	name: 'auction',
	data() {
		return {
			auctionTitle,
			auctionUlList: [],
		}
	},

	components: {
		'v-navbar': navbar,
		'v-auctionUl': auctionUl,
	},
	computed: {
		...mapState(['wtitle', 'rback', 'auctionIndex']),
	},

	methods: {
		...mapMutations(['WTITLE', 'RBACK', 'AUCTIONINDEX']),
		// 根据标题id判断获得的数据
		_isClickId(index) {
			let userInfo = {
				userId: window.localStorage.userId
			}
			switch(index) {
				case 1:
					this._getAuctionRecord(tokenLink.auction.all ,userInfo)
					break;
				case 3:
					this._getAuctionRecord(tokenLink.auction.delivery ,userInfo)
					break;
				case 4:
					this._getAuctionRecord(tokenLink.auction.collect ,userInfo)
					break;
				case 5:
					this._getAuctionRecord(tokenLink.auction.complete ,userInfo)
					break;
			}
		},
		// 获得全部商品记录
		_getAuctionRecord(url, userInfo) {
			this.$store.state.loadding = true
			tokenPost(url, userInfo).then(re => {
				this.$store.state.loadding = false
				if (re.status === 0) {
					this.auctionUlList = re.data
				} else {
					this.$Message.success(re.msg)
				}
			})
		},
		// 选择标题
		e_actionTitle(i) {
			this.AUCTIONINDEX(i)
			this._isClickId(this.$store.state.auctionIndex)
		},
	},

	mounted() {
		this.WTITLE('我的订单')
		this.RBACK(true)
		this._isClickId(this.$store.state.auctionIndex)
	},
}
</script>
